﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<UFPC.Models.Customer>" %>
<%@ Import Namespace="System.Globalization" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">  

    <h2><%= Html.Encode(Model.Name) %></h2>

    <fieldset>
        <legend>Customer Details</legend>

        <table class="formtable">
            <tr>
                <td class="formfield">Contact :</td>
                <td><%= Html.Encode(Model.Contact)%></td>
            </tr>
            <tr>
                <td class="formfield">Address :</td>
                <td><%= Html.Encode(Model.Address.Street)%></td>
            </tr>
            <tr>
                <td class="formfield"></td>
                <td><%= Html.Encode(Model.Address.City)%>,</td>
                <td><%= Html.Encode(Model.Address.Area)%></td>
            </tr>
            <tr>
                <td class="formfield">Phone :</td>
                <td><%= Html.Encode(Model.Phone)%></td>
            </tr>
            <tr>
                <td class="formfield">Fax :</td>
                <td><%= Html.Encode(Model.Fax)%></td>
            </tr>
            
        </table>        

        <br />

        <p><%= Html.ActionLink("Add product to customer...", "AddProduct", new { id=Model.CustomerId }) %></p>

        <fieldset>
            <legend>Products</legend>

            <% if (Model.CustomerProductPrices.Count != 0) { %>
                <table>
                    <tr>
                        <th>
                            Action
                        </th>
                        <th>
                            Product
                        </th>
                        <th>
                            Packing Size
                        </th>
                        <th>
                            Quantity Per Unit
                        </th>
                        <th>
                            Unit
                        </th>
                        <th>
                            Type
                        </th>
                        <th>
                            Price
                        </th>
                    </tr>
                
                <% foreach (var item in Model.CustomerProductPrices) { %>
    
                    <tr>
                        <td>
                            <%= Html.ActionLink("Edit", "EditProduct", new { customerId = item.CustomerId, productId = item.ProductId }) %> |
                            <%= Html.ActionLink("Delete", "DeleteProduct", new { customerId = item.CustomerId, productId = item.ProductId })%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Products.Name)%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Products.PackingSize)%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Products.QuantityPerUnit)%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Products.Unit)%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Products.Type)%>
                        </td>
                        <td>
                            <%= Html.Encode(item.Price.ToString("C2", CultureInfo.CreateSpecificCulture("en-PH")))%>
                        </td>
                    </tr>
    
                <% } %>

                </table>

            <% } else { %>

                <p>No products</p>

            <% } %>

        </fieldset>
        
    </fieldset>
    <!--p-->
        <!--%= Html.ActionLink("Edit", "Edit", new { id = Model.Customer.CustomerId })%> |-->
        <!--%= Html.ActionLink("Back to List", "Index") %-->
    <!--/p-->

</asp:Content>

